﻿using System.Data;
using Loki.Data;

namespace Luna.Data.Budget
{
    /// <summary>
    /// Mapper for data interface IOperationData.
    /// </summary>
    public partial class OperationDataMapper : LunaMapper<OperationData, IOperationData>
    {
        public OperationDataMapper()
        {
            GetAllRequest = "Budget.operation_select_all";
            GetRequest = "Budget.operation_select";
            InsertRequest = "Budget.operation_insert";
            UpdateRequest = "Budget.operation_update";
            DeleteRequest = "Budget.operation_delete";
        }

        private const string NameColumnName = "Name";

        protected override void LoadCoreData(IOperationData entity, IDataRecord record)
        {
            entity.Name = record.GetString(NameColumnName);
        }

        protected override void MapSaveParameters(IDatabaseCommand command, IOperationData entity)
        {
            command.AddParameter(NameColumnName, entity.Name);
            command.AddParameter(IDParameterName, entity.PK);
        }
    }
}